package com.yoomiito.app.ui.my.teamallowance

import cn.droidlover.xdroidmvp.mvp.XPresent
import cn.droidlover.xdroidmvp.net.ApiException
import cn.droidlover.xdroidmvp.net.ApiSubscriber
import cn.droidlover.xdroidmvp.net.XApi
import com.yoomiito.app.model.my.MyTodayOrderInfo
import com.yoomiito.app.net.YmApi
import com.yoomiito.app.utils.YMToast

class TeamAllowanceOrderFmPresenter : XPresent<TeamAllowanceOrderFragment>() {

    fun list(type: Int, page: Int) {
        YmApi.getYmService()
                .teamOrderList(type.toString(), page)
                .compose(v.bindToLifecycle())
                .compose(XApi.getApiTransformerData())
                .compose(XApi.getScheduler())
                .subscribe(object : ApiSubscriber<MyTodayOrderInfo>() {
                    override fun onSuccess(t: MyTodayOrderInfo?) {
                        if (hasV())
                            v.setData(t!!)
                    }

                    override fun onFail(error: ApiException?) {
                        YMToast.showText(error?.msg)
                    }

                })

    }
}